// 13-10-2010: File created

#ifndef _TBVERSIONINFO_H_
#define _TBVERSIONINFO_H_

#define TB_PLATFORM_WINDOWS       0
#define TB_PLATFORM_LINUX         1
#define TB_PLATFORM_MACINTOSH     2
#define TB_PLATFORM_SOMETHINGELSE 1000

#define TB_COMPILER_VS6           1200
#define TB_COMPILER_VSDOTNET      1300
#define TB_COMPILER_VS2005        1400
#define TB_COMPILER_VS2008        1500
#define TB_COMPILER_VS2010        1600
#define TB_COMPILER_GPP           100

#ifndef PLATFORM

	/*
		Detect which platform this is being run on.
		Thanks go to Pixel Toaster for most of the flags.
	*/

	#if defined(WIN32) || defined(WIN64) || defined(_WIN32) || defined(_WIN64)
		#define TB_PLATFORM               TB_PLATFORM_WINDOWS
		#define TB_PLATFORM_NAME          "Windows"
	#elif defined(__APPLE__) || defined(__MACH__)
		#define TB_PLATFORM               TB_PLATFORM_MACINTOSH
		#define TB_PLATFORM_NAME          "Macintosh"
	#elif defined(linux) || defined(__linux) || defined(__linux__) || defined(__CYGWIN__)
		#define TB_PLATFORM               TB_PLATFORM_LINUX
		#define TB_PLATFORM_NAME          "Linux"
	#else
		#define TB_PLATFORM	              TB_PLATFORM_SOMETHINGELSE
		#define TB_PLATFORM_NAME          "Something Else"
	#endif

	/*
		How many bits is this system?
	*/

	// Windows
	#if (defined(_WIN64) || defined(WIN64))
		#define TB_PLATFORM_BITS          64
	// Macintosh
	#elif (defined(__LP64__) || defined(_LP64) || defined(__ppc64__))
		#define TB_PLATFORM_BITS          64
	// Linux
	#elif (defined(__x86_64__) || defined(__64BIT__) || (__WORDSIZE == 64))
		#define TB_PLATFORM_BITS          64
	#else
		#define TB_PLATFORM_BITS          32
	#endif

	/*
		Determine which compiler was used to compile this program.
	*/

	#ifdef _MSC_VER
		#define TB_COMPILER_VERSION       _MSC_VER

		#if (TB_COMPILER_VERSION >= 1600)
			#define TB_COMPILER        TB_COMPILER_VS2010
			#define TB_COMPILER_NAME   "Visual Studio 2010"
		#elif (TB_COMPILER_VERSION >= 1500)
			#define TB_COMPILER        TB_COMPILER_VS2008
			#define TB_COMPILER_NAME   "Visual Studio 2008"
		#elif (TB_COMPILER_VERSION >= 1400)
			#define TB_COMPILER           TB_COMPILER_VS2005
			#define TB_COMPILER_NAME      "Visual Studio 2005"
		#elif (TB_COMPILER_VERSION >= 1300)
			#define TB_COMPILER           TB_COMPILER_VSDOTNET
			#define TB_COMPILER_NAME      "Visual Studio .NET"
		#elif (TB_COMPILER_VERSION >= 1200)
			#define TB_COMPILER           TB_COMPILER_VS6
			#define TB_COMPILER_NAME "Visual Studio 6"
		#else
			#error This version of Visual Studio is not supported.
		#endif
	#elif defined(__GNUC__)
		#define TB_COMPILER_VERSION       (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
		
		// __VERSION__
		#define TB_COMPILER_NAME          "G++"

		#define TB_PLATFORM               TB_PLATFORM_LINUX
	#endif	

	/*
		Compiler specific options
	*/

	#if (TB_PLATFORM == TB_PLATFORM_WINDOWS)
		// Support for Windows 98
		#if TB_COMPILER_VERSION >= TB_COMPILER_VS6 && TB_COMPILER_VERSION < TB_COMPILER_VSDOTNET
			#pragma comment(linker, "/OPT:NOWIN98")
		#endif

		#if TB_COMPILER_VERSION >= TB_COMPILER_VSDOTNET
			#define TB_FAST_CALL __declspec(noinline) __fastcall
		#else
			#define TB_FAST_CALL __fastcall
		#endif
	#endif

#endif

#endif